import React from 'react';
import ReactMarkdown from 'react-markdown';
import Twemoji from 'react-twemoji';
import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
interface IProps {
  markdown: string; // 需要处理的markdown内容
}

/**
 * markdown 转为字符串文本或者HTML
 */
const MarkdownToPlainTextConverter: React.FC<IProps> = props => {
  const { markdown } = props;
  return (
    <Twemoji options={{ className: 'twemoji' }}>
      <ReactMarkdown
        remarkPlugins={[remarkGfm]}
        children={markdown}
        rehypePlugins={[rehypeRaw]}
      />
    </Twemoji>
  );
};

export default MarkdownToPlainTextConverter;
